home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / uip / send / s_arginit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-04-21  |  3.1 KB  |  119 lines

  1. /*
  2. **        S _ A R G I N I T
  3. **
  4. **  This function parses and uses the information found on the command
  5. **  line.
  6. **
  7. **
  8. **    R E V I S I O N  H I S T O R Y
  9. **
  10. **    03/31/83  GWH    Split the SEND program into component parts
  11. **
  12. */
  13.  
  14. #include "./s.h"
  15. #include "./s_externs.h"
  16.  
  17. char *UsageMessage = 
  18. "Usage:  send addrs -a hdr:val -{bct} addrs -d{ev} -f file -h host -s subj -n\n";
  19.  
  20. arginit (argc, argv)              /* parse and use the argument list    */
  21. int     argc;
  22. char   *argv[];
  23. {
  24.     char *curfld;
  25.     char *cp;
  26.     register short curarg;
  27.  
  28.     strcpy (host, locname);       /* setup default host reference       */
  29.  
  30. /*  if an argument is not a switch, assume that it is an address.
  31.  *  several of the switches merely change which header addresses are
  32.  *  to be added to.  after an argument is processed, the pointer to
  33.  *  it is nulled, so that it will no longer be visible by a system-
  34.  *  status command ("ss" on the UDel machine).
  35.  */
  36.  
  37.     for (curfld = to, curarg = 1; curarg < argc; )
  38.     {                             /* regular scan of arg list           */
  39.                   /* default to adding to To field      */
  40.     if (argv[curarg][0] != '-')
  41.         addrcat (curfld, argv[curarg], host);
  42.                   /* add it to current field            */
  43.     else {                    /* a switch                           */ 
  44.         switch (argv[curarg][1])
  45.         {
  46.             case 'a':
  47.                 if (++curarg >= argc)
  48.                 break;
  49.                 if (cp = index(argv[curarg], ':'))
  50.                 *cp++ = '\0';
  51.             addheader(argv[curarg], cp);
  52.             break;
  53.  
  54.         case 'b':         /* add to end of bcc field            */
  55.             curfld = bcc;
  56.             break;
  57.  
  58.         case 'c':         /* add to end of cc field             */
  59.             ccflag = FALSE;
  60.             curfld = cc;
  61.             break;
  62.  
  63.         case 'd':      /* alter directedit option        */
  64.             switch (argv[curarg][2]) {
  65.             case '\0':
  66.                 dflag = 0;
  67.                 break;
  68.             case 'e':
  69.                 dflag = 2;
  70.                 break;
  71.             case 'v':
  72.                 dflag = 1;
  73.                 break;
  74.             default:
  75.                 printf("bad direct edit option\n");
  76.             }
  77.             break;
  78.  
  79.         case 'f':         /* add file to end of message body    */
  80.                 if (++curarg >= argc)
  81.                 break;
  82.             strcpy (inclfile, argv[curarg]);
  83.             break;        /* file is named in next argument     */
  84.  
  85.         case 'h':         /* default hostname for addresses     */
  86.                 if (++curarg >= argc)
  87.                 break;
  88.             strcpy (host, argv[curarg]);
  89.             break;        /* host is named in next argument     */
  90.  
  91.             case 'n':
  92.                 noinputflag++;
  93.                 break;
  94.  
  95.         case 's':         /* add to end of Subject field        */
  96.             subjflag = FALSE;
  97.                 if (++curarg >= argc)
  98.                 break;
  99.             strncat (subject, argv[curarg],
  100.                 (S_BSIZE - strlen(subject) - 2));
  101.             break;        /* Subject is contained in next arg   */
  102.  
  103.         case 't':         /* add to end of To field             */
  104.             toflag = FALSE;
  105.             curfld = to;
  106.             break;
  107.  
  108.         default:
  109.             snd_abort ("unknown flag in '%s'\n%s", argv[curarg],
  110.                 UsageMessage);
  111.         }
  112.     }
  113.     if (argv[curarg])
  114.         argv[curarg++][0] = '\0';
  115.     }
  116.     if (to[0] != '\0')            /* at least one To was specified      */
  117.     toflag = FALSE;           /* so don't prompt for it             */
  118. }
  119.